{% extends "base.html" %}

{% block content %}
<script language=javascript>

function verify(form){
  if(form.frommail.value==""){
	alert("Enter the frommail please!");
	form.frommail.focus();		
       return false;
	}
  if(form.subject.value==""){
	alert("Enter the subject please!");
	form.subject.focus();		
       return false;
	}
  if(form.content.value==""){
	alert("Enter the content please!");
	form.content.focus();		
       return false;
	}
	return true;
 }

</script>
<script type="text/javascript" src="/static/js/ajax.js" ></script>
<script type='text/javascript'>
		function getmaillist(){
		ajax.send('/saveaddmail/',handle_newmail);
		}
</script>
<style>
.in
{
width:330px;
}
img
{
border:0px;
}
.uploadbox
{
display:none;
}
.editbox
{
display:none;
}
.addbox
{
display:none;
}
.helpbox
{
display:none;
}
</style>
<body >
<div id="helpbox" class="helpbox">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td class='title' align="center">How to use</td></tr>
<tr><td  align="left" class='even' style="font-size:14px;">
<li>  
一.添加发送对象: 本页面最下面的"Your sending mail list "为邮箱发送对象.可以添加多个地址群发.
  添加方法:
  1.在"Customers List"的客户列表中可以看到第二列"Action"中显示有个email的小图标.点击此小图标则可把该客户添加到待发送客户列表中.
  2.直接在本页面点击下面的"Add mail address"会拉出来一个添加发送地址的对话框,可以在这里直接添加待发送地址.
</li>
<li>  
二.如果你的邮件要发送附件,最好在您写邮件内容前先把附件添加.否则写好内容再添加会刷新页面.
</li>
<li>  
三.Your mail:为你发送件的地址,收件人看到的是以这个地址发送,可以随便改,不影响发送功能.
</li>
<li>  
四.mail subject:邮件标题
</li>
<li>  
五.content:邮件主要内容.
</li>
<li>  
六.Your sending mail list<br />
&nbsp;&nbsp;customer name:客户名<br />
&nbsp;&nbsp;to email:待发送地址<br />
&nbsp;&nbsp;Edit:点击可弹出对话框修改对应的待发送地址<br />
&nbsp;&nbsp;On list:待发送地址.当显示:<img src="/static/images/yes.gif" />时表示此地址在待发送列表.
<img src="/static/images/no.gif" />表示不对此地址发送.点击这图标可改变状态.<br />
&nbsp;&nbsp;Delete:把此地址从待发送列表中删除.
</li>
<li>  
每成功发送一封邮件则会把其中的地址从待发送列表中移到sent mail中.当在ID后面显示<img src="/static/images/no.gif" />时,表示对这个地址发送不成功,此时应检查该邮箱地址是否正确.
</li>
<br />
<input type='button' class='button' name='mysubmit'  id='mysubmit' onclick="hibox('helpbox')" value='Close'  />

</td></tr>

</table>
</div>

<div id="uploadbox" class="uploadbox">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">upload file</td></tr>
	<form name='upfile' id='upfile' action="/mailfile/" method='post'  enctype="multipart/form-data">
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Your mail</td>
<td class='even'><input type='file' name='mailfile' id="mailfile" value='' class='' /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'></td>
<td class='even'>&nbsp;
<input type="hidden" name="mid" value="0" />
<input type='submit' class='button' name='mysubmit'  id='mysubmit' value=' Upload '  />&nbsp;<input type='button' class='button' name='mysubmit'  id='mysubmit' onclick="hibox('uploadbox')" value='Close'  /></form></td></tr>

</table>
</div>



<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">
	<form name='formmail' id='formmail' action="/sendthemail/" method='post'  enctype="multipart/form-data">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">mail content&nbsp;&nbsp;<a href="javascript:notice();"><img src="/static/images/notice.gif" alt="How to use?" /></a></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>Your mail</td>
<td class='even'><input type="text" class="in" name="frommail" id="frommail" value="{{sales_obj.name}}@chinaedugrp.com" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'>File</td>
<td class='even'><input type="text" class="in" name="fileurl" id="fileurl" value="{{mailfile.fileurl}}" readonly />&nbsp;<input type="button" name="fi" value="Upload" onclick="showbox('uploadbox')" />&nbsp;<input type="button" name="clf" value="Delete" onclick="delfile('m')" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>mail subject</td>
<td class='even'><input type="text" class="in" name="subject" id="subject" value="" /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'><font color="red">*</font>content</td>
<td class='even'><textarea name="content" id="content" cols="65" rows="20" /></textarea></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'></td>

<td class='even'>&nbsp;<input type='button' class='button' name='mysubmit'  id='mysubmit' onclick="goemail(2)" value=' Send '  />&nbsp;<span id="somewrong"></span></form></td></tr>

</table>


<div id="addbox" class="addbox">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">add mail address</td></tr>
<form name='editmail' id='editmail' action="/saveaddmail/" method='post'>

<tr valign='middle' align='left'><td class='odd' width='25%'>mail</td>
<td class='even'><input type='text' name='mailaddr' id="mailaddr" value='' class='in' /></td></tr>
<tr valign='middle' align='left'><td class='odd' width='25%'></td>
<td class='even'>&nbsp;
<input type='button' class='button' name='editsubmit' onclick="addmail()"  id='addsubmit' value=' Submit '  />&nbsp;<input type='button' class='button' name='addsubmit'  id='addsubmit' onclick="hibox('addbox')" value='Close'  /></form></td></tr>

</table>
</div>

<div id="editbox" class="editbox">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">Edit mail address</td></tr>
<form name='editmail' id='editmail' action="/saveeditmail/" method='post'>

<tr valign='middle' align='left'><td class='odd' width='25%'>mail</td>
<td class='even'><input type='text' name='newmail' id="newmail" value='' class='in' /></td></tr>
<input type="hidden" name="editmid" id="editmid" value="" />
<tr valign='middle' align='left'><td class='odd' width='25%'></td>
<td class='even'>&nbsp;
<input type='button' class='button' name='editsubmit' onclick="saveemail()"  id='editsubmit' value=' Submit '  />&nbsp;<input type='button' class='button' name='mysubmit'  id='mysubmit' onclick="hibox('editbox')" value='Close'  /></form></td></tr>

</table>
</div>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">

  <span id="allmaillist">
<table width='80%' class='grid' cellspacing='1' align='center'><tr><td colspan='10' class='title' align="center">Your sending mail list&nbsp;<input type='button' class='button' name='editsubmit' onclick="showbox('addbox')"  id='addsubmit' value='Add mail address'  /></td></tr>
  <tr valign='middle' align='left'>
  <td class='odd' width='15%'>ID</td>
  <td class='even' width='20%'>customer name</td>
  <td class='odd' width='30%'>to email</td>
<td class='even' width='15%'>Edit</td>  
  <td class='odd' width='10%'>On list</td>
<td class='even' width='10%'>Delete</td>  
  </tr>

    {% for m in mail_list %}
	<span id="onemail{{m.id}}">
  <tr valign='middle' align='left'>
  <td class='odd'>{{m.id}} <span id="mm{{m.id}}"></span></td>
   <td class='even'>{{m.members.name}}</td>
   <td class='odd'><span id="cmail{{m.id}}">{{m.tomail}}</span></a></td>
<td class='even' ><a href="javascript:editmail({{m.id}},'{{m.tomail}}')"><img src="/static/images/icon_edit.gif" /></a></td>
   <td class='odd'><a href="javascript:onsending({{m.id}});"><span id="on{{m.id}}">{%if m.issend%}<img src="/static/images/yes.gif" />{%else%}<img src="/static/images/no.gif" />{%endif%}</span></a></td>
<td class='even' ><a href="javascript:delmail({{m.id}});" ><img src="/static/images/no.gif" /></a></td>
  </tr>
	</span>
  {% endfor %}

      <tr><td  class='even' colspan="10" align="right">
</td></tr>
</table>
  </span>

</td></tr>
</table>


{% endblock %}